﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 状态模式_应用实例
{
    class Work
    {
        IList<State> List = new List<State>();

        public Work()
        {
            List.Add(new ForenoonState());
            List.Add(new NoonState());
            List.Add(new AfternoonState());
            List.Add(new EveningState());
        }

        public void Working(int Hour)
        {
            bool result = false;
            foreach (State i in List)
            {
                if (result |= i.Working(Hour))
                    break;
                
            }

            if (!result)
                Console.WriteLine("未有匹配项");
        }
        //根据输入项在列表里选择和合适的类处理条件
    }
}
